package com.vision.world.survey.managers;

import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;

import com.esri.arcgisruntime.ArcGISRuntimeEnvironment;
import com.esri.arcgisruntime.layers.ArcGISMapImageLayer;

/**
 * Created by Administrator on 2017/10/26.
 */

public class AuthorizationManager {

    /**
     * 用户授权验证（目前用于地图水印）
     */
    public static void initAuthorizationMap(){
//        final String serviceFeatureURL =
//                "http://sampleserver5.arcgisonline.com/arcgis/rest/services/Elevation/WorldElevations/MapServer";
//            // create new ArcGISMap image Layer from service url
//        final ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(serviceFeatureURL);
        String strKey = "runtimelite,1000,rud7032709275,none,C6JC7XLS1M0H8YAJM150";
        ArcGISRuntimeEnvironment.setLicense(strKey);
    }

    //动态获取内存存储权限
    public static void verifyStoragePermissions(Activity activity) {
        // Check if we have write permission
        int permission = ActivityCompat.checkSelfPermission(activity,
                Manifest.permission.WRITE_EXTERNAL_STORAGE);

        if (permission != PackageManager.PERMISSION_GRANTED) {
            // We don't have permission so prompt the user
//            ActivityCompat.requestPermissions(activity,  Manifest.permission.PERMISSIONS_STORAGE,
//                    REQUEST_EXTERNAL_STORAGE);
        }
    }
}
